package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.GxMessageMapper;
import com.ruoyi.system.domain.GxMessage;
import com.ruoyi.system.service.IGxMessageService;

/**
 * 消息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-01-30
 */
@Service
public class GxMessageServiceImpl implements IGxMessageService 
{
    @Autowired
    private GxMessageMapper gxMessageMapper;

    /**
     * 查询消息
     * 
     * @param messageId 消息主键
     * @return 消息
     */
    @Override
    public GxMessage selectGxMessageByMessageId(Long messageId)
    {
        return gxMessageMapper.selectGxMessageByMessageId(messageId);
    }

    /**
     * 查询消息列表
     * 
     * @param gxMessage 消息
     * @return 消息
     */
    @Override
    public List<GxMessage> selectGxMessageList(GxMessage gxMessage)
    {
        return gxMessageMapper.selectGxMessageList(gxMessage);
    }

    public List<GxMessage> selectGxMessageListIsNotRead(Long userId)
    {
        return gxMessageMapper.selectGxMessageListIsNotRead(userId);
    }

    public int updateAllIsRead(Long userId)
    {
        return gxMessageMapper.updateAllIsRead(userId);
    }

    /**
     * 新增消息
     * 
     * @param gxMessage 消息
     * @return 结果
     */
    @Override
    public int insertGxMessage(GxMessage gxMessage)
    {
        gxMessage.setCreateTime(DateUtils.getNowDate());
        return gxMessageMapper.insertGxMessage(gxMessage);
    }

    /**
     * 修改消息
     * 
     * @param gxMessage 消息
     * @return 结果
     */
    @Override
    public int updateGxMessage(GxMessage gxMessage)
    {
        return gxMessageMapper.updateGxMessage(gxMessage);
    }

    /**
     * 批量删除消息
     * 
     * @param messageIds 需要删除的消息主键
     * @return 结果
     */
    @Override
    public int deleteGxMessageByMessageIds(Long[] messageIds)
    {
        return gxMessageMapper.deleteGxMessageByMessageIds(messageIds);
    }

    /**
     * 删除消息信息
     * 
     * @param messageId 消息主键
     * @return 结果
     */
    @Override
    public int deleteGxMessageByMessageId(Long messageId)
    {
        return gxMessageMapper.deleteGxMessageByMessageId(messageId);
    }
}
